
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module scanner</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>scanner</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/mark/projects/scanner/scanner.py">/home/mark/projects/scanner/scanner.py</a></font></td></tr></table>
    <p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="re.html">re</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="scanner.html#Scanner">Scanner</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Scanner">class <strong>Scanner</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;simple&nbsp;class&nbsp;to&nbsp;aid&nbsp;in&nbsp;lexical&nbsp;analysis&nbsp;of&nbsp;a&nbsp;string.<br>
Styled&nbsp;after,&nbsp;but&nbsp;not&nbsp;entirely&nbsp;the&nbsp;same&nbsp;as,&nbsp;Ruby's&nbsp;StringScanner&nbsp;class.<br>
&nbsp;<br>
Basic&nbsp;philosophy&nbsp;is&nbsp;simple:&nbsp;<a href="#Scanner">Scanner</a>&nbsp;traverses&nbsp;a&nbsp;string&nbsp;left&nbsp;to&nbsp;right,<br>
consuming&nbsp;the&nbsp;string&nbsp;as&nbsp;it&nbsp;goes.&nbsp;The&nbsp;current&nbsp;position&nbsp;is&nbsp;the&nbsp;string&nbsp;pointer<br>
<a href="#Scanner">Scanner</a>.pos.&nbsp;At&nbsp;each&nbsp;iteration,&nbsp;the&nbsp;caller&nbsp;uses&nbsp;the&nbsp;scanning&nbsp;methods&nbsp;to&nbsp;<br>
determine&nbsp;what&nbsp;the&nbsp;current&nbsp;piece&nbsp;of&nbsp;string&nbsp;actually&nbsp;is.<br>
&nbsp;<br>
Scanning&nbsp;methods:<br>
&nbsp;&nbsp;With&nbsp;the&nbsp;exception&nbsp;of&nbsp;get&nbsp;and&nbsp;peek,&nbsp;all&nbsp;scanning&nbsp;methods&nbsp;take&nbsp;a&nbsp;pattern&nbsp;and<br>
&nbsp;&nbsp;(optionally)&nbsp;flags&nbsp;(e.g&nbsp;re.X).&nbsp;The&nbsp;patterns&nbsp;are&nbsp;assumed&nbsp;to&nbsp;be&nbsp;either&nbsp;<br>
&nbsp;&nbsp;strings&nbsp;or&nbsp;compiled&nbsp;regular&nbsp;expression&nbsp;objects&nbsp;(i.e.&nbsp;the&nbsp;result&nbsp;of&nbsp;<br>
&nbsp;&nbsp;re.compile,&nbsp;or&nbsp;equivalent).&nbsp;If&nbsp;a&nbsp;pattern&nbsp;is&nbsp;not&nbsp;a&nbsp;string&nbsp;but&nbsp;does&nbsp;not&nbsp;<br>
&nbsp;&nbsp;implement&nbsp;match&nbsp;or&nbsp;search&nbsp;(whichever&nbsp;is&nbsp;being&nbsp;used),&nbsp;a&nbsp;ValueError&nbsp;is&nbsp;raised.<br>
&nbsp;&nbsp;String&nbsp;patterns&nbsp;are&nbsp;compiled&nbsp;and&nbsp;cached&nbsp;internally.<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;The&nbsp;check,&nbsp;scan&nbsp;and&nbsp;skip&nbsp;methods&nbsp;all&nbsp;try&nbsp;to&nbsp;match&nbsp;*at*&nbsp;the&nbsp;current&nbsp;scan<br>
&nbsp;&nbsp;pointer.&nbsp;check_to,&nbsp;scan_to&nbsp;and&nbsp;skip_to&nbsp;all&nbsp;try&nbsp;to&nbsp;find&nbsp;a&nbsp;match&nbsp;somewhere<br>
&nbsp;&nbsp;beyond&nbsp;the&nbsp;scan&nbsp;pointer&nbsp;and&nbsp;jump&nbsp;*to*&nbsp;that&nbsp;position.&nbsp;check_until,&nbsp;scan_until,<br>
&nbsp;&nbsp;and&nbsp;skip_until&nbsp;are&nbsp;like&nbsp;*_to,&nbsp;but&nbsp;also&nbsp;consume&nbsp;the&nbsp;match&nbsp;(so&nbsp;the&nbsp;jump&nbsp;to<br>
&nbsp;&nbsp;the&nbsp;*end*&nbsp;of&nbsp;that&nbsp;position)<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;Lookahead:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-check">check</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-check_to">check_to</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-check_until">check_until</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-peek">peek</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;Consume:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-get">get</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-scan">scan</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-scan_to">scan_to</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-scan_until">scan_until</a>()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-skip">skip</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-skip_to">skip_to</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-skip_until">skip_until</a>()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-skip_bytes">skip_bytes</a>()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(convenience&nbsp;wrapper)<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-skip_lines">skip_lines</a>()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(convenience&nbsp;wrapper)<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Scanner-skip_whitespace">skip_whitespace</a>()&nbsp;(convenience&nbsp;wrapper)<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;Note&nbsp;that&nbsp;scan*&nbsp;and&nbsp;check*&nbsp;both&nbsp;return&nbsp;either&nbsp;a&nbsp;string,&nbsp;in&nbsp;the&nbsp;case&nbsp;of&nbsp;a<br>
&nbsp;&nbsp;match,&nbsp;or&nbsp;None,&nbsp;in&nbsp;the&nbsp;case&nbsp;of&nbsp;no&nbsp;match.&nbsp;If&nbsp;the&nbsp;match&nbsp;exists&nbsp;but&nbsp;is&nbsp;zero<br>
&nbsp;&nbsp;length,&nbsp;the&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned.&nbsp;Be&nbsp;careful&nbsp;handling&nbsp;this&nbsp;as&nbsp;both&nbsp;<br>
&nbsp;&nbsp;None&nbsp;and&nbsp;the&nbsp;empty&nbsp;string&nbsp;evaluate&nbsp;to&nbsp;False,&nbsp;but&nbsp;mean&nbsp;very&nbsp;different&nbsp;things.<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;peek&nbsp;and&nbsp;get&nbsp;also&nbsp;return&nbsp;the&nbsp;empty&nbsp;string&nbsp;when&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;stream&nbsp;is&nbsp;<br>
&nbsp;&nbsp;reached.<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Most&nbsp;recent&nbsp;match&nbsp;data:<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<a href="#Scanner-matched">matched</a>()&nbsp;--&nbsp;True/False&nbsp;-&nbsp;was&nbsp;the&nbsp;most&nbsp;recent&nbsp;match&nbsp;a&nbsp;success?<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;The&nbsp;following&nbsp;methods&nbsp;all&nbsp;throw&nbsp;Exception&nbsp;if&nbsp;not&nbsp;<a href="#Scanner-matched">matched</a>()<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<a href="#Scanner-match">match</a>()&nbsp;--&nbsp;matched&nbsp;string<br>
&nbsp;&nbsp;<a href="#Scanner-match_len">match_len</a>()&nbsp;--&nbsp;matched&nbsp;string&nbsp;length<br>
&nbsp;&nbsp;<a href="#Scanner-match_pos">match_pos</a>()&nbsp;--&nbsp;offset&nbsp;of&nbsp;match<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;Wrappers&nbsp;around&nbsp;re.*<br>
&nbsp;&nbsp;<a href="#Scanner-match_info">match_info</a>()&nbsp;&nbsp;--&nbsp;the&nbsp;re.MatchObject<br>
&nbsp;&nbsp;<a href="#Scanner-match_group">match_group</a>()<br>
&nbsp;&nbsp;<a href="#Scanner-match_groups">match_groups</a>()<br>
&nbsp;&nbsp;<a href="#Scanner-match_groupdict">match_groupdict</a>()<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<a href="#Scanner-pre_match">pre_match</a>()&nbsp;--&nbsp;string&nbsp;preceding&nbsp;the&nbsp;match<br>
&nbsp;&nbsp;<a href="#Scanner-post_match">post_match</a>()&nbsp;--&nbsp;string&nbsp;following&nbsp;the&nbsp;match<br>
&nbsp;&nbsp;<br>
Misc:<br>
&nbsp;&nbsp;pos&nbsp;--&nbsp;get/set&nbsp;current&nbsp;scan&nbsp;pointer&nbsp;position<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<a href="#Scanner-bol">bol</a>()&nbsp;--&nbsp;beginning&nbsp;of&nbsp;line?&nbsp;(DOS/Unix/Mac&nbsp;aware)<br>
&nbsp;&nbsp;<a href="#Scanner-eol">eol</a>()&nbsp;--&nbsp;end&nbsp;of&nbsp;line?&nbsp;(DOS/Unix/Mac&nbsp;aware)<br>
&nbsp;&nbsp;<a href="#Scanner-eos">eos</a>()&nbsp;--&nbsp;end&nbsp;of&nbsp;string?<br>
&nbsp;&nbsp;<a href="#Scanner-rest">rest</a>()&nbsp;--&nbsp;remaining&nbsp;(unconsumed)&nbsp;string<br>
&nbsp;&nbsp;<a href="#Scanner-rest_len">rest_len</a>()&nbsp;--&nbsp;length&nbsp;of&nbsp;remaining&nbsp;string<br>
&nbsp;&nbsp;<a href="#Scanner-unscan">unscan</a>()&nbsp;--&nbsp;revert&nbsp;to&nbsp;previous&nbsp;state<br>
&nbsp;&nbsp;<br>
Setup:<br>
&nbsp;&nbsp;string&nbsp;--&nbsp;get/set&nbsp;current&nbsp;source&nbsp;string<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<a href="#Scanner-reset">reset</a>()&nbsp;--&nbsp;reset&nbsp;the&nbsp;scanner&nbsp;ready&nbsp;to&nbsp;start&nbsp;again<br>
&nbsp;&nbsp;<a href="#Scanner-terminate">terminate</a>()&nbsp;--&nbsp;trigger&nbsp;premature&nbsp;finish<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Scanner-__init__"><strong>__init__</strong></a>(self, src<font color="#909090">=None</font>)</dt><dd><tt>Constructor&nbsp;<br>
&nbsp;<br>
Arguments:<br>
src&nbsp;--&nbsp;a&nbsp;string&nbsp;to&nbsp;scan.&nbsp;This&nbsp;can&nbsp;be&nbsp;set&nbsp;later&nbsp;by&nbsp;<a href="#Scanner-string">string</a>()</tt></dd></dl>

<dl><dt><a name="Scanner-bol"><strong>bol</strong></a>(self)</dt><dd><tt>Return&nbsp;whether&nbsp;or&nbsp;not&nbsp;the&nbsp;scan&nbsp;pointer&nbsp;is&nbsp;immediately&nbsp;after&nbsp;a&nbsp;newline<br>
character&nbsp;(DOS/Unix/Mac&nbsp;aware),&nbsp;or&nbsp;at&nbsp;the&nbsp;start&nbsp;of&nbsp;the&nbsp;string.</tt></dd></dl>

<dl><dt><a name="Scanner-check"><strong>check</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Return&nbsp;a&nbsp;match&nbsp;for&nbsp;the&nbsp;pattern&nbsp;(or&nbsp;None)&nbsp;at&nbsp;the&nbsp;scan&nbsp;pointer&nbsp;without&nbsp;<br>
actually&nbsp;consuming&nbsp;the&nbsp;string<br>
If&nbsp;the&nbsp;pattern&nbsp;matched&nbsp;but&nbsp;was&nbsp;zero&nbsp;length,&nbsp;the&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned<br>
If&nbsp;the&nbsp;pattern&nbsp;did&nbsp;not&nbsp;match,&nbsp;None&nbsp;is&nbsp;returned</tt></dd></dl>

<dl><dt><a name="Scanner-check_to"><strong>check_to</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Return&nbsp;all&nbsp;text&nbsp;up&nbsp;until&nbsp;the&nbsp;beginning&nbsp;of&nbsp;the&nbsp;first&nbsp;match&nbsp;for&nbsp;the&nbsp;pattern&nbsp;<br>
after&nbsp;the&nbsp;scan&nbsp;pointer&nbsp;without&nbsp;consuming&nbsp;the&nbsp;string<br>
If&nbsp;the&nbsp;pattern&nbsp;matched&nbsp;but&nbsp;was&nbsp;zero&nbsp;length,&nbsp;the&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned<br>
If&nbsp;the&nbsp;pattern&nbsp;did&nbsp;not&nbsp;match,&nbsp;None&nbsp;is&nbsp;returned</tt></dd></dl>

<dl><dt><a name="Scanner-check_until"><strong>check_until</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Return&nbsp;all&nbsp;text&nbsp;up&nbsp;until&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;first&nbsp;match&nbsp;for&nbsp;the&nbsp;pattern&nbsp;<br>
after&nbsp;the&nbsp;scan&nbsp;pointer&nbsp;without&nbsp;consuming&nbsp;the&nbsp;string<br>
If&nbsp;the&nbsp;pattern&nbsp;matched&nbsp;but&nbsp;was&nbsp;zero&nbsp;length,&nbsp;the&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned<br>
If&nbsp;the&nbsp;pattern&nbsp;did&nbsp;not&nbsp;match,&nbsp;None&nbsp;is&nbsp;returned</tt></dd></dl>

<dl><dt><a name="Scanner-eol"><strong>eol</strong></a>(self)</dt><dd><tt>Return&nbsp;whether&nbsp;or&nbsp;not&nbsp;the&nbsp;scan&nbsp;pointer&nbsp;is&nbsp;immediately&nbsp;before&nbsp;a&nbsp;newline&nbsp;<br>
character&nbsp;(DOS/Unix/Mac&nbsp;aware)&nbsp;or&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;string.</tt></dd></dl>

<dl><dt><a name="Scanner-eos"><strong>eos</strong></a>(self)</dt><dd><tt>Return&nbsp;True&nbsp;iff&nbsp;we&nbsp;are&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;string,&nbsp;else&nbsp;False.</tt></dd></dl>

<dl><dt><a name="Scanner-get"><strong>get</strong></a>(self, length<font color="#909090">=1</font>)</dt><dd><tt>Return&nbsp;the&nbsp;given&nbsp;number&nbsp;of&nbsp;characters&nbsp;from&nbsp;the&nbsp;current&nbsp;string&nbsp;pointer&nbsp;<br>
and&nbsp;consume&nbsp;them<br>
If&nbsp;we&nbsp;reach&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;stream,&nbsp;the&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned</tt></dd></dl>

<dl><dt><a name="Scanner-match"><strong>match</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;last&nbsp;matching&nbsp;string<br>
Raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded.<br>
Raise&nbsp;Exception&nbsp;if&nbsp;most&nbsp;recent&nbsp;match&nbsp;failed</tt></dd></dl>

<dl><dt><a name="Scanner-match_group"><strong>match_group</strong></a>(self, *args)</dt><dd><tt>Return&nbsp;the&nbsp;contents&nbsp;of&nbsp;the&nbsp;given&nbsp;group&nbsp;in&nbsp;the&nbsp;most&nbsp;recent&nbsp;match.<br>
This&nbsp;is&nbsp;a&nbsp;wrapper&nbsp;to&nbsp;re.MatchObject.group()<br>
raise&nbsp;IndexError&nbsp;if&nbsp;the&nbsp;match&nbsp;exists&nbsp;but&nbsp;the&nbsp;group&nbsp;does&nbsp;not<br>
raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded<br>
raise&nbsp;Exception&nbsp;if&nbsp;most&nbsp;recent&nbsp;match&nbsp;failed</tt></dd></dl>

<dl><dt><a name="Scanner-match_groupdict"><strong>match_groupdict</strong></a>(self, default<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;a&nbsp;dict&nbsp;containing&nbsp;group_name&nbsp;=&gt;&nbsp;match.&nbsp;This&nbsp;is&nbsp;a&nbsp;wrapper&nbsp;to<br>
re.MatchObject.groupdict()&nbsp;and&nbsp;as&nbsp;such&nbsp;it&nbsp;only&nbsp;works&nbsp;for&nbsp;named&nbsp;groups<br>
&nbsp;<br>
Raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded.<br>
Raise&nbsp;Exception&nbsp;if&nbsp;most&nbsp;recent&nbsp;match&nbsp;failed</tt></dd></dl>

<dl><dt><a name="Scanner-match_groups"><strong>match_groups</strong></a>(self, default<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;the&nbsp;most&nbsp;recent's&nbsp;match's&nbsp;groups,&nbsp;this&nbsp;is&nbsp;a&nbsp;wrapper&nbsp;to&nbsp;<br>
re.MatchObject.groups()<br>
&nbsp;<br>
Raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded.<br>
Raise&nbsp;Exception&nbsp;if&nbsp;most&nbsp;recent&nbsp;match&nbsp;failed</tt></dd></dl>

<dl><dt><a name="Scanner-match_info"><strong>match_info</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;most&nbsp;recent&nbsp;match's&nbsp;MatchObject.&nbsp;This&nbsp;is&nbsp;what's&nbsp;returned&nbsp;by<br>
the&nbsp;re&nbsp;module.&nbsp;Use&nbsp;this&nbsp;if&nbsp;the&nbsp;other&nbsp;methods&nbsp;here&nbsp;don't&nbsp;expose&nbsp;what&nbsp;you&nbsp;<br>
need.<br>
Raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded.<br>
Raise&nbsp;Exception&nbsp;if&nbsp;most&nbsp;recent&nbsp;match&nbsp;failed</tt></dd></dl>

<dl><dt><a name="Scanner-match_len"><strong>match_len</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;length&nbsp;of&nbsp;the&nbsp;last&nbsp;matching&nbsp;string<br>
This&nbsp;is&nbsp;equivalent&nbsp;to&nbsp;len(scanner.<a href="#Scanner-match">match</a>()).<br>
&nbsp;<br>
Raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded.<br>
Raise&nbsp;Exception&nbsp;if&nbsp;most&nbsp;recent&nbsp;match&nbsp;failed</tt></dd></dl>

<dl><dt><a name="Scanner-match_pos"><strong>match_pos</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;offset&nbsp;into&nbsp;the&nbsp;string&nbsp;of&nbsp;the&nbsp;last&nbsp;match<br>
Raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded.<br>
Raise&nbsp;Exception&nbsp;if&nbsp;most&nbsp;recent&nbsp;match&nbsp;failed</tt></dd></dl>

<dl><dt><a name="Scanner-matched"><strong>matched</strong></a>(self)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;the&nbsp;last&nbsp;match&nbsp;was&nbsp;successful,&nbsp;else&nbsp;False.<br>
Raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded.</tt></dd></dl>

<dl><dt><a name="Scanner-peek"><strong>peek</strong></a>(self, length<font color="#909090">=1</font>)</dt><dd><tt>Return&nbsp;the&nbsp;given&nbsp;number&nbsp;of&nbsp;characters&nbsp;from&nbsp;the&nbsp;current&nbsp;string&nbsp;pointer<br>
without&nbsp;consuming&nbsp;them.<br>
If&nbsp;we&nbsp;reach&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;stream,&nbsp;the&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned</tt></dd></dl>

<dl><dt><a name="Scanner-post_match"><strong>post_match</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;string&nbsp;following&nbsp;the&nbsp;last&nbsp;match&nbsp;or&nbsp;None.&nbsp;This&nbsp;is&nbsp;equivalent&nbsp;<br>
to:&nbsp;&nbsp;scanner.string[scanner.<a href="#Scanner-match_pos">match_pos</a>()&nbsp;+&nbsp;scanner.<a href="#Scanner-match_len">match_len</a>()&nbsp;:&nbsp;]<br>
&nbsp;<br>
raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded</tt></dd></dl>

<dl><dt><a name="Scanner-pre_match"><strong>pre_match</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;string&nbsp;preceding&nbsp;the&nbsp;last&nbsp;match&nbsp;or&nbsp;None.&nbsp;This&nbsp;is&nbsp;equivalent&nbsp;<br>
to:&nbsp;&nbsp;scanner.string[:scanner.<a href="#Scanner-match_pos">match_pos</a>()]<br>
&nbsp;<br>
raise&nbsp;Exception&nbsp;if&nbsp;no&nbsp;match&nbsp;attempts&nbsp;have&nbsp;been&nbsp;recorded</tt></dd></dl>

<dl><dt><a name="Scanner-reset"><strong>reset</strong></a>(self)</dt><dd><tt>Reset&nbsp;the&nbsp;scanner's&nbsp;state&nbsp;including&nbsp;string&nbsp;pointer&nbsp;and&nbsp;match&nbsp;history.</tt></dd></dl>

<dl><dt><a name="Scanner-rest"><strong>rest</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;string&nbsp;from&nbsp;the&nbsp;current&nbsp;pointer&nbsp;onwards,&nbsp;i.e.&nbsp;the&nbsp;segment&nbsp;of&nbsp;<br>
string&nbsp;which&nbsp;has&nbsp;not&nbsp;yet&nbsp;been&nbsp;consumed.</tt></dd></dl>

<dl><dt><a name="Scanner-rest_len"><strong>rest_len</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;length&nbsp;of&nbsp;string&nbsp;remaining.&nbsp;<br>
This&nbsp;is&nbsp;equivalent&nbsp;to&nbsp;len(<a href="#Scanner-rest">rest</a>())</tt></dd></dl>

<dl><dt><a name="Scanner-scan"><strong>scan</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Return&nbsp;a&nbsp;match&nbsp;for&nbsp;the&nbsp;pattern&nbsp;at&nbsp;the&nbsp;scan&nbsp;pointer&nbsp;and&nbsp;consume&nbsp;the&nbsp;<br>
string.<br>
Return&nbsp;None&nbsp;if&nbsp;not&nbsp;match&nbsp;is&nbsp;found</tt></dd></dl>

<dl><dt><a name="Scanner-scan_to"><strong>scan_to</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Return&nbsp;all&nbsp;text&nbsp;up&nbsp;until&nbsp;the&nbsp;beginning&nbsp;of&nbsp;the&nbsp;first&nbsp;match&nbsp;for&nbsp;the&nbsp;pattern<br>
after&nbsp;the&nbsp;scan&nbsp;pointer.<br>
The&nbsp;pattern&nbsp;is&nbsp;not&nbsp;included&nbsp;in&nbsp;the&nbsp;match.<br>
The&nbsp;scan&nbsp;pointer&nbsp;will&nbsp;be&nbsp;moved&nbsp;such&nbsp;that&nbsp;it&nbsp;immediately&nbsp;precedes&nbsp;the&nbsp;pattern<br>
Return&nbsp;None&nbsp;if&nbsp;no&nbsp;match&nbsp;is&nbsp;found</tt></dd></dl>

<dl><dt><a name="Scanner-scan_until"><strong>scan_until</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Return&nbsp;the&nbsp;first&nbsp;match&nbsp;for&nbsp;the&nbsp;pattern&nbsp;after&nbsp;the&nbsp;scan&nbsp;pointer&nbsp;and&nbsp;<br>
consumes&nbsp;the&nbsp;string&nbsp;up&nbsp;until&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;match.&nbsp;&nbsp;&nbsp;&nbsp;<br>
Return&nbsp;None&nbsp;if&nbsp;no&nbsp;match&nbsp;is&nbsp;found</tt></dd></dl>

<dl><dt><a name="Scanner-skip"><strong>skip</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Scan&nbsp;ahead&nbsp;over&nbsp;the&nbsp;given&nbsp;pattern&nbsp;and&nbsp;return&nbsp;how&nbsp;many&nbsp;characters&nbsp;were<br>
consumed,&nbsp;or&nbsp;None.<br>
Similar&nbsp;to&nbsp;scan,&nbsp;but&nbsp;does&nbsp;not&nbsp;return&nbsp;the&nbsp;string&nbsp;or&nbsp;record&nbsp;the&nbsp;match</tt></dd></dl>

<dl><dt><a name="Scanner-skip_bytes"><strong>skip_bytes</strong></a>(self, n)</dt><dd><tt>Skip&nbsp;the&nbsp;given&nbsp;number&nbsp;of&nbsp;bytes&nbsp;and&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;bytes&nbsp;consumed</tt></dd></dl>

<dl><dt><a name="Scanner-skip_lines"><strong>skip_lines</strong></a>(self, n<font color="#909090">=1</font>)</dt><dd><tt>Skip&nbsp;the&nbsp;given&nbsp;number&nbsp;of&nbsp;lines&nbsp;and&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;lines&nbsp;consumed</tt></dd></dl>

<dl><dt><a name="Scanner-skip_to"><strong>skip_to</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Scan&nbsp;ahead&nbsp;until&nbsp;the&nbsp;beginning&nbsp;of&nbsp;first&nbsp;occurrance&nbsp;of&nbsp;the&nbsp;given&nbsp;pattern<br>
and&nbsp;return&nbsp;how&nbsp;many&nbsp;characters&nbsp;were&nbsp;skipped,&nbsp;or&nbsp;None&nbsp;if&nbsp;the&nbsp;match<br>
failed<br>
The&nbsp;match&nbsp;is&nbsp;not&nbsp;recorded.</tt></dd></dl>

<dl><dt><a name="Scanner-skip_until"><strong>skip_until</strong></a>(self, pattern, flags<font color="#909090">=0</font>)</dt><dd><tt>Scan&nbsp;ahead&nbsp;until&nbsp;the&nbsp;end&nbsp;of&nbsp;first&nbsp;occurrance&nbsp;of&nbsp;the&nbsp;given&nbsp;pattern&nbsp;and&nbsp;<br>
return&nbsp;how&nbsp;many&nbsp;characters&nbsp;were&nbsp;consumed,&nbsp;or&nbsp;None&nbsp;if&nbsp;the&nbsp;match&nbsp;failed<br>
The&nbsp;match&nbsp;is&nbsp;not&nbsp;recorded</tt></dd></dl>

<dl><dt><a name="Scanner-skip_whitespace"><strong>skip_whitespace</strong></a>(self, n<font color="#909090">=None</font>, multiline<font color="#909090">=True</font>)</dt><dd><tt>Skip&nbsp;over&nbsp;whitespace&nbsp;characters&nbsp;and&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;characters&nbsp;<br>
consumed<br>
&nbsp;<br>
Arguments:&nbsp;<br>
n&nbsp;--&nbsp;maximum&nbsp;number&nbsp;of&nbsp;characters&nbsp;to&nbsp;cosume&nbsp;(default&nbsp;None)<br>
multiline&nbsp;--&nbsp;whether&nbsp;or&nbsp;not&nbsp;to&nbsp;consume&nbsp;newline&nbsp;characters&nbsp;(default&nbsp;True)</tt></dd></dl>

<dl><dt><a name="Scanner-terminate"><strong>terminate</strong></a>(self)</dt><dd><tt>Set&nbsp;the&nbsp;string&nbsp;pointer&nbsp;to&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;input&nbsp;and&nbsp;clear&nbsp;the&nbsp;match&nbsp;<br>
history.</tt></dd></dl>

<dl><dt><a name="Scanner-unscan"><strong>unscan</strong></a>(self)</dt><dd><tt>Revert&nbsp;the&nbsp;scanner's&nbsp;state&nbsp;to&nbsp;that&nbsp;of&nbsp;the&nbsp;previous&nbsp;match.&nbsp;Only&nbsp;one&nbsp;<br>
previous&nbsp;state&nbsp;is&nbsp;remembered<br>
Throw&nbsp;Exception&nbsp;if&nbsp;there&nbsp;is&nbsp;no&nbsp;previous&nbsp;known&nbsp;state&nbsp;to&nbsp;restore</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>pos</strong></dt>
<dd><tt>The&nbsp;current&nbsp;string&nbsp;pointer&nbsp;position.</tt></dd>
</dl>
<dl><dt><strong>string</strong></dt>
<dd><tt>The&nbsp;source&nbsp;string</tt></dd>
</dl>
</td></tr></table></td></tr></table>
</body></html>